package com.mall.controller;

import com.mall.commons.common.CommonResult;
import com.mall.model.domain.CmsSubject;
import com.mall.model.vo.PageResult;
import com.mall.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    /**
     * 根据专题名称分页获取商品专题
     * @param pageNum
     * @param pageSize
     * @param keyword
     * @return
     */
    @GetMapping("/list")
    public CommonResult querySubjectByPage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize,
                                           String keyword) {
        PageResult pr = subjectService.querySubjectByPage(pageNum, pageSize, keyword);
        return CommonResult.success(pr);
    }


    /**
     * 获取全部商品专题
     * @return
     */
    @GetMapping("/listAll")
    public CommonResult queryAllSubject() {
        List<CmsSubject> list = subjectService.queryAllSubject();
        return CommonResult.success(list);
    }



}
